home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 26
/
Cream of the Crop 26.iso
/
program
/
ddj0897.zip
/
DYN401.ZIP
/
dpp
/
arglist.c
next >
Wrap
C/C++ Source or Header
|
1997-04-16
|
3KB
|
148 lines
/* Copyright (c) 1993-1996 Algorithms Corporation */
/* All rights reserved. */
/* This file automatically generated by dpp - do not edit */
#define DPP_STRATEGY 2
#define DPP_FASTWIDE 0
#line 17 "arglist.d"
#include "dpp.h"
#define CLASS ArgumentList_c
#define ivType ArgumentList_iv_t
#include "generics.h"
object ArgumentList_c;
#line 21 "arglist.d"
static void process_file(object, char *);
cmeth objrtn ArgumentList_cm_gNew(object self)
{
return gShouldNotImplement(self, "gNew");
}
cmeth objrtn ArgumentList_cm_gNewArglist(object self, int argc, char **argv)
{
int i;
object obj = oSuper(ArgumentList_c, gNew, self)(self);
for (i=0 ; i < argc ; i++)
if (argv[i][0] == '@')
process_file(obj, 1+argv[i]);
else
gAddLast(obj, gNewWithStr(String, argv[i]));
return obj;
}
static void process_word(char *word, object list, int noexpand)
{
int wild=0;
char *w;
if (!noexpand)
for (w=word ; *w ; w++)
if (*w == '*' || *w == '?') {
wild = 1;
break;
}
if (!wild) {
gAddLast(list, gNewWithStr(String, word));
return;
}
gAddLast(list, gNewWithStr(String, word));
}
#define space(x) ((x) <= ' ')
static char *process_token(char *p, object list)
{
char word[128], *w;
int inquote, noexpand;
while (*p && space(*p))
p++;
if (noexpand = inquote = *p == '"')
p++;
for (w=word ; *p && (!space(*p) || inquote) ; p++)
if (inquote && *p == '"')
inquote = 0;
else
*w++ = *p;
*w = '\0';
if (*word == '@')
process_file(list, word+1);
else if (*word)
process_word(word, list, noexpand);
return p;
}
static void process_file(object list, char *file)
{
char buf[256], *p;
object fobj;
fobj = gOpenFile(File, file, "r");
if (!fobj) {
vPrintf(stdoutStream, "Can't open %s\n", file);
exit(1);
}
while (gGets(fobj, buf, sizeof buf))
for (p=buf ; *(p=process_token(p, list)) ; );
gDispose(fobj);
}
#line 109 "arglist.c"
objrtn ArgumentList_initialize(void)
{
static CRITICALSECTION cs;
static int volatile once = 0;
ENTERCRITICALSECTION(_CI_CS_);
if (!once) {
INITIALIZECRITICALSECTION(cs);
once = 1;
}
LEAVECRITICALSECTION(_CI_CS_);
ENTERCRITICALSECTION(cs);
if (ArgumentList_c) {
LEAVECRITICALSECTION(cs);
return ArgumentList_c;
}
INHIBIT_THREADER;
LinkObject_initialize();
if (ArgumentList_c) {
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return ArgumentList_c;
}
ArgumentList_c = gNewClass(Class, "ArgumentList", 0, 0, LinkObject, END);
cMethodFor(ArgumentList, gNew, ArgumentList_cm_gNew);
cMethodFor(ArgumentList, gNewArglist, ArgumentList_cm_gNewArglist);
ENABLE_THREADER;
LEAVECRITICALSECTION(cs);
return ArgumentList_c;
}